package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.anno.Log;
import org.example.pojo.Personal;
import org.example.pojo.Result;
import org.example.service.PasswordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/password")
public class PasswordController {
    @Autowired
    private  PasswordService passwordService;

    @Log
    @PutMapping
    public Result updatePassword(@RequestBody Personal personal) {
        Integer i = passwordService.updatePassword(personal);
        if (i == 0) {
            return Result.error("原密码错误");
        }
        return Result.success();
    }
}
